package glossos.tree.factory;

import glossos.tree.Node;
import glossos.tree.snapshot.NodeRepository;
import glossos.tree.snapshot.PersistentNodeMap;

public class PersistentNodeFactory extends AbstractNodeFactory {

	private NodeRepository nodeRepository;

	public PersistentNodeFactory(NodeRepository nodeRepository) {
		this.nodeRepository = nodeRepository;
	}

	public Node create(String word, Integer frequency) {
		Node node = new Node();
		node.setChildren(new PersistentNodeMap(node, nodeRepository));
		node.setId(nodeRepository.nextId());
        node.setWord(word);
        node.setFrequency(frequency);
        return node;
	}
}
